/*
 * Authors: Alex Attar & Kevin El Hage
 * ID: 9765727
 * Date: 9/3/2012
 * 
 */

package taskManagerSystem.ControllerSubsystem;

import javax.swing.JFrame;

import taskManagerSystem.ModelSubsystem.Model;
import taskManagerSystem.ViewSubsystem.View;

/*
 * The Controller class manages communication between the controls, the model and the view.
 * Namely, it adds event listeners to the view, which in turn are used to inform the model 
 * of actions to be performed on the data and the view that the model has been updated.  
 */
public class Controller {
	protected Model model;
	protected View view;
	protected JFrame window;
	
	public Controller(){}
	
	/*
	 * The constructor receives references to the model and view, then passes
	 * the listeners to be used to the view.
	 */
	public Controller(Model model, View view) {
		this.model = model;
		this.view = view;
		
		view.addTaskTableListener(new TaskTableListener(model, view));
		view.addActionListeners(new Listener(model, view));
		view.addWindowSaveOnExitListener(new WindowSaveOnExitListener(model, view));
		
	}
	
	/*
	 * start() simply informs the view that it must be visible, effectively starting the system.
	 */
	public void start(){
		view.setVisible(true);
	}
}
